<template>
	<view>
		<view style="font-size:28rpx;line-height:20px;color: #999;padding:20px;">提示：用户每秒产生的金币*设置的时间（秒）=  用户看完视频获得的金币。</view>
		<view class="uni-container" style="float: left;">
			<uni-forms ref="form" validateTrigger="bind">
				<uni-forms-item label="看视频收益时间(秒)" name="title" labelWidth="150">
					<input class="uni-input-border" type="text" v-model="globalinfo.videocoin" />
				</uni-forms-item>
				
				<view class="uni-button-group pointer">
					<button class="uni-button uni-button-full" type="primary" :disabled="isLoading" @click="save">保存</button>
				</view>
			</uni-forms>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isLoading:false,
				"globalinfo":{
					"videocoin":0,
				},    
					
			}
		},
		methods: {
			getinfo(){
				var self = this
				this.isLoading = true
				self.data = []
				this.$request('admin/loadconfig',{id:'globalinfo'}).then(res => {
					this.isLoading = false
					var json = res.config
					self.globalinfo = json
					console.log(res)
				}).catch(res => {
				
				}).finally(err => {
					this.isLoading = false
				})
			},
			save(){
				var self = this
				self.isLoading = true
				delete self.globalinfo._id;
				for(let key in self.globalinfo){
					if(key != '_id'){
						self.globalinfo[key] = self.globalinfo[key]
					}
				}
				console.log(self.globalinfo)
				self.$request('admin/setconfig',{json:JSON.stringify({globalinfo:self.globalinfo})}).then(res => {
					self.isLoading = false
					uni.showToast({
						title: "修改成功",
						icon: 'none',
						duration: 2000
					})
				}).catch(res => {
				
				}).finally(err => {
					this.isLoading = false
				})
			}
		},
		mounted() {
			var self = this
			self.getinfo()
		}
	}
</script>

<style>

</style>
